<?php
session_start(); 
if(!isset($_SESSION['userName'])){
header( 'location:../index.php' ); 
}
include("../conf/connect.php");
	$serial=$_GET['serial'];
	$user_id = $_SESSION['user_id'];
	$hid = $_SESSION['usrHHid']; 
	$respondent = $_SESSION['hello'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />
	<link rel="shortcut icon" href="images/favicon.ico" />
</head>
<body class="iub_back">
		<?php if ($serial=='med01'){ 
				
		?>
		<form action="answer.php?qus=med01" method="post">
				<table align="center" class="table_border" >
					<tr align="left">
							<td align="left" valign="top"> Medications:</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED01: Taken any medications in the past 1 mnth?</td>
					</tr>
					<?php 
							$sql="SELECT  med01 FROM med1 WHERE hid = '$hid' and resp_id = '$respondent'";
							$result = mysql_query($sql) or die ("problem budget_heads");
							$row = mysql_fetch_assoc($result);
					?>
					<tr align="left">
							<td align="left" valign="top"></td>
					</tr>
					<tr align="left">
							<td align="left" <?php if($row["med01"] == ''||$row["med01"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<select name="med01">
									 <?php
											if($row["med01"] == ''||$row["med01"] == '0'){
											 echo "<option value='0' selected='selected'> Select</option>";
											}
											else{
												$hop=$row["med01"];
												$sql1="SELECT value from retreive_data WHERE qus='spn02_a' and hoption='$hop' ";
												$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
												$value = mysql_fetch_assoc($result1);
												$mv= $value['value'];
												echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
											}
										?>
									<option value="1">1-Yes</option>
									<option value="3">3-No</option>
								</select>					
							</td>
					</tr>
					<tr>
							<td  align="right">
								<input type="submit" value="Next" class="input-box" />&nbsp;
							</td>
					</tr>	
				</table>
		</form>
		<?php } ?>
		<?php if ($serial=='med02'){ 
				
				//echo "<pre>";
				//print_r($row );
		?>
		<form action="answer.php?qus=med02" method="post">
				<table align="center" class="table_border" >
					<tr align="left">
							<td align="left" valign="top"> Medications:</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED02: How many?</td>
					</tr>
					<?php 
							$sql="SELECT  med02 FROM med1 WHERE hid = '$hid' and resp_id = '$respondent'";
							$result = mysql_query($sql) or die ("problem budget_heads");
							$row = mysql_fetch_assoc($result);
					?>
					<tr align="left">
							<td align="left" <?php if($row["med02"] == ''||$row["med02"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<select name="t1">
									 <?php for($i=0;$i<=9;$i++){?>
									 <option value="<?php echo $i;?>"><?php echo $i;?></option>
									 <?php }?>
								</select>					
							</td>
					</tr>
					<tr>
							<td  align="right">
								<input type="submit" value="Next" class="input-box" />&nbsp;
							</td>
					</tr>	
				</table>
		</form>
		<?php } ?>
		<?php if ($serial=='med03'){ 
				$no=$_GET['no'];
				if($no=='')$no=1;				
				$sql="SELECT  med3, med4, med5, med6, med7, med8, med9 FROM med2 WHERE hid = '$hid' and resp_id = '$respondent' and status=0 ";
				$result = mysql_query($sql) or die ("problem budget_heads");
				$row = mysql_fetch_assoc($result);
		?>
		<form action="answer.php?qus=med03" method="post">
		<input type="hidden" name="no" value="<?php echo $no;?>" />
				<table align="center" class="table_border" >
					<tr align="left">
							<td align="left" valign="top"> Medications:</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top"> Medicine &nbsp;<?php echo $no;?>:</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED03: For which diseases medicine is taken? </td>
					</tr>
					<tr align="left">
							<td align="left" <?php if($row["med3"] == ''||$row["med3"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<input type="text" name="med3" />					
							</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED04: Medicine name? </td>
					</tr>
					<tr align="left">
							<td align="left" <?php if($row["med4"] == ''||$row["med4"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<input type="text" name="med4" />					
							</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED05: Is this medicine taken in last month?</td>
					</tr>
					<tr align="left">
							<td align="left" <?php if($row["med5"] == ''||$row["med5"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<select name="med5">
									 <?php
											if($row["med5"] == ''||$row["med5"] == '0'){
											 echo "<option value='0' selected='selected'> Select</option>";
											}
											else{
												$hop=$row["med5"];
												$sql1="SELECT value from retreive_data WHERE qus='spn02_a' and hoption='$hop' ";
												$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
												$value = mysql_fetch_assoc($result1);
												$mv= $value['value'];
												echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
											}
										?>
									<option value="1">1-Yes</option>
									<option value="3">3-No</option>
								</select>					
							</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED06: Taken this medicine ystrday?</td>
					</tr>
					<tr align="left">
							<td align="left" <?php if($row["med6"] == ''||$row["med6"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<select name="med6">
									 <?php
											if($row["med6"] == ''||$row["med6"] == '0'){
											 echo "<option value='0' selected='selected'> Select</option>";
											}
											else{
												$hop=$row["med6"];
												$sql1="SELECT value from retreive_data WHERE qus='spn02_a' and hoption='$hop' ";
												$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
												$value = mysql_fetch_assoc($result1);
												$mv= $value['value'];
												echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
											}
										?>
									<option value="1">1-Yes</option>
									<option value="3">3-No</option>
								</select>					
							</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED07: Frequency of taking this medicine last month?</td>
					</tr>
					<tr align="left">
							<td align="left" <?php if($row["med7"] == ''||$row["med7"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<select name="d1">
									 <?php for($i=0;$i<=3;$i++){?>
									 <option value="<?php echo $i;?>"><?php echo $i;?></option>
									 <?php }?>
								</select>	
								<select name="d2">
									 <?php for($i=0;$i<=9;$i++){?>
									 <option value="<?php echo $i;?>"><?php echo $i;?></option>
									 <?php }?>
								</select> &nbsp;&nbsp;days				
							</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED08: Prescribed by?</td>
					</tr>
					<tr align="left">
							<td align="left" <?php if($row["med8"] == ''||$row["med8"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<select name="med8">
									 <?php
											if($row["med8"] == ''||$row["med8"] == '0'){
											 echo "<option value='0' selected='selected'> Select</option>";
											}
											else{
												$hop=$row["med8"];
												$sql1="SELECT value from retreive_data WHERE qus='am06' and hoption='$hop' ";
												$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
												$value = mysql_fetch_assoc($result1);
												$mv= $value['value'];
												echo "<option value='$hop' selected='selected'> $hop.&nbsp;$mv</option>";
											}
										?>
									<?php for($i=1;$i<=18;$i++){
											$hop=$i;
											$sql1="SELECT value from retreive_data WHERE qus='am06' and hoption='$hop' ";
											$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
											$value = mysql_fetch_assoc($result1);
											$mv= $value['value'];
											echo "<option value='$hop'> $hop-$mv</option>";
									} ?>
								</select>				
							</td>
					</tr>
					<tr align="left">
							<td align="left" valign="top">MED09: Cost for medicine(last mnth)?</td>
					</tr>
					<tr align="left">
							<td align="left" <?php if($row["med9"] == ''||$row["med9"] == '0'){?>bgcolor="#F7A244"<?php }?>>
								<input type="text" name="med9" /> &nbsp;&nbsp;tk			
							</td>
					</tr>
					<tr>
							<td  align="right">
								<input type="submit" value="Next" class="input-box" />&nbsp;
							</td>
					</tr>	
				</table>
		</form>
		<?php } ?>
</body>
</html>